/**
* @Description: WoShop商城
* @Author: 梧桐
* @Copyright: 武汉一一零七科技有限公司©版权所有
* @Link: www.s1107.com
* @Contact: QQ:2487937004
*/
<template>
  <view class="team">
    <view class="tab-content">
      <view class="item" v-for="(item, index) in list" :key="index">
        <image :src="item.headimgurl" />
        <view class="tab-item__right flex1">
          <h2>{{ item.phone }}</h2>
          <view>
            级别:
            <span>{{ item.level }}级</span>
          </view>
        </view>
        <view class="item-time">{{ $utils.fomartTime(item.addtime) }}</view>
      </view>
      <loadMore :loadingType="loadingType"></loadMore>
    </view>
  </view>
</template>

<script>
let params = {
  size: "10",
  page: 1,
  filter: 1
};
export default {
  data() {
    return {
      pageShow: false,
      page: 1,
      isMore: false,
      list: [],
      isLoading: false,
      loadingType: 0
    };
  },
  
  onReachBottom() {
    this.loadMoreFunc();
  },
  onPullDownRefresh() {
    this.$nextTick(() => {
      this.getDistributionTeamInfo(
          {
            size: "10",
            page: 1,
            filter: 1
          },
          true
      );
    });
  },
  onLoad() {
    this.getDistributionTeamInfo(params);
  },
  methods: {
    getDistributionTeamInfo(data, refrash) {
      if (this.page == 1) {
        this.$loading();
      }
      this.$http
          .getDistributionTeamInfo(data)
          .then(res => {
            if (res.status === 200) {
              this.$hideLoading();
              if (refrash) {
                this.list = res.data.friendres.data;
                this.loadingType = 0;
                return false;
              }
              if (res.data.friendres.data.length == 0) {
                // console.log(12346789)
                this.loadingType = 2;
                return false;
              }
              this.list = this.list.concat(res.data.friendres.data);
              this.loadingType = 0;
            }
            // uni.stopPullDownRefresh();
          })
          .catch(() => {
            // uni.stopPullDownRefresh();
          });
    },
    loadMoreFunc: function() {
      // 加载函数
      if (this.loadingType == 1 || this.loadingType == 2) {
        return false;
      }
      this.loadingType = 1;
      // console.log(999999)
      ++this.page;
      params.page = this.page;
      this.$nextTick(() => {
        this.getDistributionTeamInfo(params);
      });
    }
  }
};
</script>

<style lang="less">
page {
  background: #f7f7f7;
}

.tab {
  display: flex;
  position: fixed;
  align-items: center;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100upx;
  text-align: center;
  color: #333;
  background: #fff;
  
  span {
    position: relative;
    flex: 1;
  }
  
  span.active {
    color: #fa3f3f;
  }
  span.active::before {
    background: #fa3f3f;
  }
  
  span::before {
    position: absolute;
    left: 50%;
    bottom: -20upx;
    width: 50upx;
    height: 6upx;
    border-radius: 3upx;
    transform: translateX(-50%);
    background: transparent;
    content: " ";
  }
}

.tab-content {
  padding-top: 10upx;
  
  .item {
    display: flex;
    align-items: center;
    height: 118upx;
    margin-top: 16upx;
    padding: 0 24upx;
    background: #fff;
    
    image {
      width: 80upx;
      height: 80upx;
      margin-right: 20upx;
      border-radius: 50%;
    }
    
    .tab-item__right {
      color: #666;
      font-size: 26upx;
      
      h2 {
        margin-bottom: 18upx;
        font-size: 32upx;
        color: #333;
      }
      
      span {
        display: inline-block;
        padding-left: 20upx;
      }
    }
    
    .item-time {
      font-size: 26upx;
      color: #999;
    }
  }
}
</style>
